package com.bzqn.baseframe;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;
import android.view.View;

public class BZQNFrameEventSingleInstance {

	public static final String LOG_TAG = "BZQN";
	private static BZQNFrameEventSingleInstance mBZQNFrameEventSingleInstance = null;
	private static List<BZQNFrameEvnetListener> listeners = null;
	public void sendTabChangeEvent(int index){
		for (int i = 0; i < listeners.size(); i++) {
			listeners.get(i).onTabChange(index);
		}
	}
	public void sendLeftNavicationClickEvent(View view){
		for (int i = 0; i < listeners.size(); i++) {
			listeners.get(i).onLeftNavicationButtonClick(view);
		}
	}
	public void sendRightNavicationClickEvent(View view){
		for (int i = 0; i < listeners.size(); i++) {
			listeners.get(i).onRightNavicationButtonClick(view);
		}
	}
	public void addListener(BZQNFrameEvnetListener listener){
		if(listener != null){
			listeners.add(listener);
		}else {
			Log.i(LOG_TAG,"addListener params is null");
		}
	}
	public void removeListener(BZQNFrameEvnetListener listener){
		if(listener != null){
			listeners.remove(listener);
		}
	}
	private BZQNFrameEventSingleInstance(){
		
	}
	
	public static BZQNFrameEventSingleInstance getInstance(){
		if(mBZQNFrameEventSingleInstance == null){
			mBZQNFrameEventSingleInstance = new BZQNFrameEventSingleInstance();
			listeners = new ArrayList<BZQNFrameEvnetListener>();
		}
		return mBZQNFrameEventSingleInstance;
	}
	
	
}

